package com.caldremch.demo

/**
 * Created by Administrator on 2017/10/31.
 * 循环控制
 */

fun main(args: Array<String>) {

    //for循环可以对任何提供迭代器的对象进行遍历
//    for(item in colletion) print(item)

//    for (item:Int in ints){
//        ...
//    }
    //创建
    val items = listOf("apple", "slslls");


    var array = arrayOf(1,2,3,4);
    //通过索引遍历数组
    for(i in array.indices){
        print(array[i])
    }

    //index & value circulation 使用withIndex
    for ((index, value) in array.withIndex()){
        println("the element a $index is $value")
    }

    loop@ for (i in 1..10){
        for(j in 1..10){
            if (i == 2) break@loop
        }
    }

}

